package com.twu.bm.football;

import com.sun.deploy.util.StringUtils;

import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;

public class Player {

    private String name;
    private int age;
    private String team;
    private int number;

    public Player(String name, int age, String teamName, int number) {
        this.name = name;
        this.age = age;
        this.team = teamName;
        this.number = number;
    }

    public void print(PrintStream printStream) {
        printStream.println(name);
        printStream.println(age);
        printStream.println(team);
        printStream.println(number);
    }


    public boolean checkMatches(String name, String number) {
        int testNumber;
        try {
            testNumber = Integer.parseInt(number);
        } catch (NumberFormatException ex) {
            return false;
        }

        return (name.equals(this.name)) && (testNumber==this.number);
    }

    public String info() {
        List<String> attributes = new ArrayList<String>();
        attributes.add(name);
        attributes.add(team);
        attributes.add("" + number);
        attributes.add("" + age);

        return StringUtils.join(attributes, " ");
    }
}
